package com.example.restaurantclient.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.restaurantclient.ConfigUtil.ConfigUtil;
import com.example.restaurantclient.Entities.Order;
import com.example.restaurantclient.R;

import java.util.List;


public class ShopRecordAdapter extends BaseAdapter {
    private Context mContext;
    private List<Order> orders;
    private int itemLayoutRes;

    public ShopRecordAdapter(Context mContext, List<Order> orders, int itemLayoutRes) {
        this.mContext = mContext;
        this.orders = orders;
        this.itemLayoutRes = itemLayoutRes;
    }

    @Override
    public int getCount() {
        if (null != orders){
            return orders.size();
        }
        return 0;
    }

    @Override
    public Object getItem(int i) {
        if (null != orders){
            return orders.get(i);
        }
        return null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        LayoutInflater inflater = LayoutInflater.from(mContext);//布局填充器
        view = inflater.inflate(itemLayoutRes, null);

        TextView tvName = view.findViewById(R.id.tv_commodity);
        TextView tvIntegral = view.findViewById(R.id.tv_scoring);
        TextView tvInte2 = view.findViewById(R.id.list_item_sum_price);
        ImageView imageView = view.findViewById(R.id.img_goods);

        tvName.setText(orders.get(i).getGoods_name());
        tvIntegral.setText(orders.get(i).getGoods_integral()+"");

//        Glide.with(mContext)
//                .load(ConfigUtil.SERVER_ADDR+"img/"+orders.get(i).getGoods_picture())
//                .into(imageView);
        return view;
    }
}
